
def walkDictTree(parent,dictChild):
    '''
    Loop a Tree:
    Tree structure is:
        dict={}
        dict[parentNode]=[childNode1,childNode2,childNode3,...]
        Each childNode Could Only have 1 patentNode
    Example:
    0
    1 2 3
        4 5 6
            7 8 9
    :param parent:
    :param dictChild:
    :return:
    '''

    # print 'input',parent,dictChild

    if isinstance(dictChild,dict):
        # it must has 1 len dict
        if len(dictChild) != 1:
            print '[Error]: it must has 1 len dict'
        k1 = dictChild.keys()[0]
        v1 = dictChild[k1]
        parent = '%s.%s'%(parent,k1)
        # print 'Parent:',parent

        if isinstance(v1,list):
            # print 'list',v1
            for i in v1:
                if isinstance(i,dict):
                    walkDictTree(parent,i)
                else:
                    curr = '%s.%s'%(parent,i)
                    print curr
        elif isinstance(v1,dict):
            walkDictTree(parent,v1)
    else:
        print '[Error]:', dictChild

if __name__ =="__main__":
    # dict: {a:[b:{}]}
    d= {0:[1,{2:[22,23]},{3:[4,5,{6:[7,8,9]}]}]}
    print d
    walkDictTree('',d)

